define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.merchant_orders/index',
        add_url: 'mall.merchant_orders/add',
        edit_url: 'mall.merchant_orders/edit',
        delete_url: 'mall.merchant_orders/delete',
        export_url: 'mall.merchant_orders/export',
        modify_url: 'mall.merchant_orders/modify',
        stock_url: 'mall.merchant_orders/stock',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '支付拆分',
                        title: '是否支付？',
                        url: init.add_url,
                        method: 'post',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        extend: 'data-full="true"',
                    }],
                    'delete', 'export'],
                cols: [[
                    { type: "checkbox" },
                    { field: 'ordernum', width: 80, title: '订单号' },
                    { field: 'goods_id', width: 100, title: '商品id' },
                    { field: 'goods', minWidth: 80, title: '商品名' },
                    { field: 'price', width: 100, title: '商品价格' },
                    { field: 'bug_num', width: 100, title: '商品数量' },
                    { field: 'user_id', width: 100, title: '购买的用户' },
                    { field: 'shop_id', width: 100, title: '归属商家' },
                    { field: 'status', minWidth: 100, title: '订单状态' },
                    { field: 'createtime', minWidth: 80, title: '创建时间', search: 'range' },
                    {
                        minWidth: 100,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        stock: function () {
            ea.listen();
        },
    };
    return Controller;
});